﻿using System;

namespace PPClasses
{
    public class Pair
    {
        public int a { get; set; }
        public int b { get; set; }

        public Pair()
        {
        }

        public Pair(int aa, int bb)
        {
            a = aa;
            b = bb;
        }

        public override bool Equals(Object o)
        {
            Pair p2 = o as Pair;
            if ((object)p2 == null)
                return false;

            return (this.a == p2.a && this.b == p2.b);
        }

        static public bool operator ==(Pair a, Pair b)
        {
            // If both are null, or both are same instance, return true.
            if (ReferenceEquals(a, b))
            {
                return true;
            }

            // If one is null, but not both, return false.
            if (((object)a == null) || ((object)b == null))
            {
                return false;
            }

            return (a.a == b.a && a.b == b.b);
        }

        static public bool operator !=(Pair a, Pair b)
        {
            return !(a == b);
        }

        public bool same(Pair o)
        {
            return ((o.a == a && o.b == b) || (o.a == b && o.b == a));
        }

        public override int GetHashCode()
        {
            return base.GetHashCode() ^ a ^ b;
        }
    }
}